/**
 * This class calcules points that a person obtains acoording to payment history
 */
package com.src.uniandes.ecos.tsp.creditscore.algorithm;

import com.src.uniandes.ecos.tsp.creditscore.exception.CreditScoreException;

/**
 *
 * @author Luis Carlos Caliz Daza
 */
public class PaymentHistory {

    /**
     * Returns the point numbers that client obtains according with this payment
     * history.
     * @param codigo that calculate the history.
     * @return double the total score obtained.
     * @throws CreditScoreException
     */

    public final double getPointsPaymentHistory(final Integer codigo) throws
            CreditScoreException{
        try{
           final RulesPaymentHistory rules = new RulesPaymentHistory();
           final double paymentsOnTime = rules.getPointsPaymentsOnTime(codigo);
           final double numberOfAccountsAsociated = rules.
                   getPointsNumberOfAccountsAssociated(codigo);
           final double pointsAccordingToDebt = rules.
                   getPointsAccordingToDebt(codigo);
           final double pointsOfNegativeRatings = rules.
                   getPointsOfNegativeRatings(codigo);
           final double result = paymentsOnTime + numberOfAccountsAsociated
                   + pointsAccordingToDebt + pointsOfNegativeRatings;
           return result;
        }catch(Exception e){
            throw new CreditScoreException("PaymentHistory:"+ e.toString(), e);
        }
    }
}
